package cn.com.dhcc.ddi.task.service;

import java.util.List;

import cn.com.dhcc.app.core.exception.DaoException;
import cn.com.dhcc.app.core.exception.ServiceException;
import cn.com.dhcc.app.core.handler.modulehandler.WhereCondition;
import cn.com.dhcc.app.core.handler.pagerhandler.Pager;
import cn.com.dhcc.app.core.handler.pagerhandler.PagerData;
import cn.com.dhcc.app.core.service.BaseService;
import cn.com.dhcc.ddi.task.dao.TaskExecuteLogDao;
import cn.com.dhcc.ddi.task.vo.TaskExecuteLog;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @日期：2016/11/18 14:20
 * @作者：张洪涛
 * @版权所有：东华软件
 * @版本：1.0
 */
@Service
public class TaskExecuteLogService extends BaseService {
    @Autowired
    private TaskExecuteLogDao dao;
    /**
     * 获取对象
     * @param id
     * @return
     * @throws DaoException
     */
    public TaskExecuteLog get(String id) throws ServiceException {
        try {
            return dao.get(id);
        } catch (DaoException e) {
            throw new ServiceException(e);
        }
    }
    public int insert(TaskExecuteLog obj) throws ServiceException {
        try {
            return dao.insert(obj);
        } catch (DaoException e) {
            throw new ServiceException(e);
        }
    }
    public int update(TaskExecuteLog obj) throws ServiceException {
        try {
            return dao.update(obj);
        } catch (DaoException e) {
            throw new ServiceException(e);
        }
    }
    public int insertOrUpdate(TaskExecuteLog obj) throws ServiceException {
        try {
            return dao.insertOrUpdate(obj);
        } catch (DaoException e) {
            throw new ServiceException(e);
        }
    }
    
    public int deleteByTaskId(String taskId) throws ServiceException {
    	try {
            return dao.deleteByTaskId(taskId);
        } catch (DaoException e) {
            throw new ServiceException(e);
        }
    }
    
    /**
     * 获取任务执行日志数
     * @param taskId
     * @return
     * @throws ServiceException
     */
    public int getCount(String taskId) throws ServiceException{
		try {
			return dao.getCount(taskId);
		} catch (DaoException e) {
			throw new ServiceException("获取任务执行日志数失败", e);
		}
	}
    
    public PagerData<TaskExecuteLog> getTaskLogPagerListByTaskId(Pager pager, WhereCondition searchData, String taskId) throws ServiceException {
    	try {
			return dao.getTaskLogPagerList(pager, searchData, taskId);
		} catch (DaoException e) {
			throw new ServiceException("获取任务执行日志数失败", e);
		}
    }
    
    
    public List<TaskExecuteLog> getSubTasksByGroupId(String id, WhereCondition searchData) throws ServiceException {
    	try {
			return dao.getSubTaskByGroupId(id, searchData);
		} catch (DaoException e) {
			throw new ServiceException("获取任务执行日志数失败", e);
		}
    }

    /**
     * 获取任务环节日志
     * @param groupId 大任务id
     * @param linktype 环节类型
     * @return
     * @throws ServiceException
     */
   public TaskExecuteLog getLinkLog(String groupId,String linktype)throws ServiceException {
       try {
           return dao.getLinkLog(groupId,linktype);
       } catch (DaoException e) {
           throw new ServiceException("获取任务环节日志数失败", e);
       }
   }
}
